package com.y.config.imageConfig;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author: Yjh
 */
@Configuration
public class ImageConfig implements WebMvcConfigurer {
    /**
     * 需要配置虚拟文件路径的映射
     * 上传文件不需要重启访问
     * @param registry
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        String rootPath = System.getProperty("user.dir");
        String filePath = rootPath+"\\src\\main\\resources\\static\\img\\";
        registry.addResourceHandler("/img/**").addResourceLocations("file:\\"+filePath);
    }
}
